package com.example.demo.thread;

public class ThreadTest1 extends Thread {

    @Override
    public void run() {
        while (true) {
            System.out.println("Hello from " + this.getName() + this.currentThread().getId());
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

    public static void main(String[] args) {
        ThreadTest1 t1 = new ThreadTest1();
        t1.setName("Thread-1");
        System.out.println("Starting thread: " + t1.getName());
        t1.start();

        ThreadTest1 t2 = new ThreadTest1();
        t2.setName("Thread-2");
        System.out.println("Starting thread: " + t2.getName());
        t2.start();
    }


}
